import React from 'react'
import { useHistory } from 'react-router-dom'
import '@/assets/userlist.scss'


export default props => {
  console.log( props )

  const route = useHistory()
  const user = [
    { id: 1, username: 'admin', password: 'abcdef' },
    { id: 2, username: 'host', password: '123456' },
    { id: 3, username: '时梦人', password: '123456' }
  ]

  const skipDetail = item => {
    route.push('/detail/' + item.id)
  }

  return (
    <div className="user-list">
      <h3>用户列表</h3>
      <ul className="users">
        {
          user.map(item => (
            <li key={ item.id } onClick={ () => skipDetail(item) }>{ item.username }</li>
          ))
        }
      </ul>
    </div>
  )
}